package Chapter_11_Work;
// 11.1
import java.util.Date;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Please enter three sides: ");
        double side1 = input.nextDouble();
        double side2 = input.nextDouble();
        double side3 = input.nextDouble();
        System.out.println("Enter color: ");
        String str = input.next();
        System.out.println("Enter filled: ");
        boolean filled = input.nextBoolean();
        Triangle t = new Triangle(side1,side2, side3);
        t.setColor(str);
        t.setFilled(filled);
        System.out.println("The area:" + t.getArea());
        System.out.println("The perimeter:" + t.getPerimeter());
        System.out.println("The color:" + t.getColor());
        System.out.println("The filled:" + t.isFilled());
    }

}

class GeometricObject {
    private String color = "white";
    private boolean filled;
    private Date dateCreated;
    public GeometricObject() {
        dateCreated = new Date();
    }

    public GeometricObject(String color, boolean filled) {
        dateCreated = new Date();
        this.color = color;
        this.filled = filled;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public boolean isFilled() {
        return filled;
    }

    public void setFilled(boolean filled) {
        this.filled = filled;
    }

    public Date getDateCreate() {
        return dateCreated;
    }

    public String toString() {
        return "created on " + dateCreated + "\ncolor: " + color + " and filled: " + filled;
    }

}

class Triangle extends GeometricObject {
    private double side1 =1.0;
    private double side2 =1.0;
    private double side3 =1.0;

    public Triangle(){
        super();
    }

    public Triangle(double side1, double side2, double side3){
        super();
        this.side1 = side1;
        this.side2 = side2;
        this.side3 = side3;
    }

    public double getSide1() {
        return side1;
    }

    public double getSide2() {
        return side2;
    }

    public double getSide3() {
        return side3;
    }

    public double getArea(){
        double p = (side1 + side2+ side3) / 2;
        return Math.sqrt(p * (p - side1) * (p - side2) * (p - side3));
    }

    public double getPerimeter(){
        return side1 + side2 +side3;
    }

    public String toString(){
        return "Triangle: side1 = " +side1 +" side2 = " + side2 + " side3 = " + side3;
    }
}